package com.chuan.state;

//测试礼让线程
public class TestYield {
    public static void main(String[] args) {
        MyYield myYield = new MyYield();

        new Thread(myYield,"a").start();
        new Thread(myYield,"b").start();
    }
}

class MyYield implements Runnable{
    @Override
    public void run() {
        System.out.println("线程"+Thread.currentThread().getName()+"开始");
        Thread.yield();
        System.out.println("线程"+Thread.currentThread().getName()+"停止");
    }
}
